package g_proxy.a_remote.server;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * Created by wug on 2016/7/4 0004.
 */
public class Server {

    public static void main(String[] args){
        new Server();
    }

    public Server(){
        try {
            RemoteService rm = new RomoteServiceImpl();
            RemoteService stub = (RemoteService)UnicastRemoteObject.exportObject(rm, 0);

            // Bind the remote object's stub in the registry
            Registry registry = LocateRegistry.getRegistry();
            registry.bind(Config.OBJECT_NAME, stub);
            System.out.println("Server is running...");
        } catch (Exception e) {
            System.out.println("Server startup failed!");
            e.printStackTrace();
        }
    }
}
